﻿<phone:PhoneApplicationPage 
    x:Class="ActivityTracker.Monthly_TimeSpentBarChart"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="728" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False"
    Loaded="PhoneApplicationPage_Loaded">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="{StaticResource bipivot}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" >
            <TextBlock x:Name="ApplicationTitle" Foreground="White" Text="ACTIVITY TRACKER- GROUPED BY ACTIVITY" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal" Grid.Row="0">
                <toolkit:ListPicker Height="48" Foreground="White" HorizontalAlignment="Left" x:Name="lpicMonth" VerticalAlignment="Top" Width="170" Margin="10,10,0,0">
                    <toolkit:ListPicker.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock x:Name="item" Foreground="White" Text="{Binding}" FontSize="26" Margin="10, 0, 0, 8" />
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:ListPicker.ItemTemplate>
                </toolkit:ListPicker>
                <toolkit:ListPicker Height="48" Foreground="White" x:Name="lpicYear" VerticalAlignment="Top" Width="170" Margin="10,10,0,0" HorizontalAlignment="Center" >
                    <toolkit:ListPicker.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock x:Name="item" Foreground="White" Text="{Binding}" FontSize="26" Margin="10, 0, 0, 8" />
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:ListPicker.ItemTemplate>
                </toolkit:ListPicker>
                <StackPanel x:Name="stkpnl" Orientation="Vertical"  Width="100" HorizontalAlignment="Right"  VerticalAlignment="Top">
                    <Button x:Name="btnok" Foreground="White" Content="OK" Width="100" HorizontalAlignment="Right" VerticalAlignment="Top" Click="btnok_Click" Margin="10, 6, 0, 8"></Button>
                </StackPanel>
            </StackPanel>
            <StackPanel Grid.Row="1">
                <ScrollViewer x:Name="scrvwrchart" Height="560" Width="480" VerticalScrollBarVisibility="Visible">
                    <charting:Chart x:Name="BarChart" Margin="6,20,13,0" MinHeight="550">
                        <charting:Chart.Series>
                            <charting:BarSeries x:Name="barseries" DependentValuePath="ActDur" IndependentValuePath="ActName" ItemsSource="{Binding}">
                                <charting:BarSeries.DependentRangeAxis>
                                    <charting:LinearAxis Minimum="0" Orientation="X" ShowGridLines="True"></charting:LinearAxis>
                                </charting:BarSeries.DependentRangeAxis>
                                <charting:BarSeries.IndependentAxis>
                                    <charting:CategoryAxis Orientation="Y" >
                                        <charting:CategoryAxis.AxisLabelStyle>
                                            <Style TargetType="charting:AxisLabel">
                                                <Setter Property="Visibility" Value="Collapsed"/>
                                            </Style>
                                        </charting:CategoryAxis.AxisLabelStyle>
                                    </charting:CategoryAxis>
                                </charting:BarSeries.IndependentAxis>
                                <charting:BarSeries.DataPointStyle>
                                    <Style TargetType="charting:BarDataPoint">
                                        <Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/>
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="charting:BarDataPoint">
                                                    <Grid>
                                                        <Rectangle Fill="{TemplateBinding Background}" Stroke="Black" Height="50"/>
                                                        <Grid Margin="20, -5, -350, 0" HorizontalAlignment="Left" VerticalAlignment="Center" Height="50">
                                                            <TextBlock Text="{TemplateBinding FormattedIndependentValue}" Width="400" FontWeight="Light" Margin="2" Foreground="{StaticResource PhoneForegroundBrush}" VerticalAlignment="Center"/>
                                                        </Grid>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </charting:BarSeries.DataPointStyle>
                            </charting:BarSeries>
                        </charting:Chart.Series>
                    </charting:Chart>
                </ScrollViewer>
            </StackPanel>
            <TextBlock Grid.Row="1" VerticalAlignment="Center" Foreground="White" HorizontalAlignment="Center" x:Name="txtblkResult" Text="Data not available for this month" Visibility="Collapsed"/>
        </Grid>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar >
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" x:Name="myappbar" >
            <shell:ApplicationBarIconButton x:Name="btnPieChart" IconUri="/Images/piechart.png" Text="pie chart" Click="btnPieChart_Click"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="group by category" Click="ApplicationBarMenuItem_Click"></shell:ApplicationBarMenuItem>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
